package example.Bricklet.GPS;
import com.tinkerforge.BrickletGPS;
import com.tinkerforge.IPConnection;

public class ExampleSimple {
	private static final String host = "localhost";
	private static final int port = 4223;
	private static final String UID = "ABC"; // Change to your UID

	// Note: To make the examples code cleaner we do not handle exceptions.
	// Exceptions you
	// might normally want to catch are described in the commnents below
	public static void main(final String args[]) throws Exception {
		final IPConnection ipcon = new IPConnection(); // Create IP connection
		final BrickletGPS gps = new BrickletGPS(ExampleSimple.UID, ipcon); // Create
																			// device
																			// object

		ipcon.connect(ExampleSimple.host, ExampleSimple.port); // Connect to
																// brickd
		// Don't use device before ipcon is connected

		// Get current coordinates
		final BrickletGPS.Coordinates coords = gps.getCoordinates(); // Can
																		// throw
																		// com.tinkerforge.TimeoutException

		System.out.println("Latitude: " + (coords.latitude / 1000000.0) + "° "
				+ coords.ns);
		System.out.println("Longitude: " + (coords.longitude / 1000000.0)
				+ "° " + coords.ew);

		System.console().readLine("Press key to exit\n");
		ipcon.disconnect();
	}
}
